home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C24 / RTTIandNesting.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  466 b   |  23 lines

  1. //: C24:RTTIandNesting.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include <iostream>
  7. #include <typeinfo>
  8. using namespace std;
  9.  
  10. class One {
  11.   class Nested {};
  12.   Nested* n;
  13. public:
  14.   One() : n(new Nested) {}
  15.   ~One() { delete n; }
  16.   Nested* nested() { return n; }
  17. };
  18.  
  19. int main() {
  20.   One o;
  21.   cout << typeid(*o.nested()).name() << endl;
  22. } ///:~
  23.